import { BeforeInsert, BeforeUpdate, Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class Banner {
    @PrimaryGeneratedColumn({
        comment:'主键id'
    })
    id: number;

    @Column({
        unique: true,
        comment:'广告标识',
        length:50
    })
    identity: string;

    @Column({
        comment:'广告名'
    })
    name: string;

    @Column({
        nullable: true,
        comment:'描述'
    })
    desc: string;

    @Column({
        type: 'text',
        comment:'广告'
    })
    banners: string;

    @Column({
        type: 'tinyint',
        comment:'状态 1显示 0隐藏'
    })
    status: number;

    @Column({
        type: 'bigint',
        update:false,
        comment:'创建时间'
    })
    create_time: number;

    @Column({
        type: 'bigint',
        comment:'修改时间'
    })
    update_time: number;

    @BeforeInsert()
    beforeInsert() {
        this.create_time = new Date().getTime();
        this.update_time = new Date().getTime();
    }

    @BeforeUpdate()
    beforeUpdate() {
        this.update_time = new Date().getTime();
    }
}
